import { GameDataModel } from './GameDataModel';
import { FinishView } from './ui_view/FinishView';
import { GameView } from './ui_view/GameView';
import {StartView} from './ui_view/StartView';

const scoreLabelContent: string = 'Score:';
export class UIController implements GameCtrler{
    private startView: StartView;
    private gameView: GameView;
    private finishView: FinishView;

    public constructor(){
        this.startView = new StartView(cc.find('game/start_view'));

        this.gameView = new GameView(cc.find('game/game_view'));

        this.finishView = new FinishView(cc.find('game/finish_view'));
    }

    prepareGame(): void {
        this.startView.show();
        this.gameView.hide();
        this.finishView.hide();
    }

    startGame(): void {
        this.startView.hide();
        this.gameView.show();
        this.finishView.hide();
    }

    finishGame(): void {
        this.startView.hide();
        this.gameView.hide();
        
        let curScore = GameDataModel.getInstance().getScore();
        let bestScore = GameDataModel.getInstance().getBestScore();
        this.finishView.setData(curScore, bestScore);
        this.finishView.show();
    }

    restartGame(): void {
        this.startGame();
    }
}